import*as e from"../../models/issues_manager/issues_manager.js";import*as t from"../../core/i18n/i18n.js";import*as s from"../../ui/legacy/legacy.js";import*as i from"../../ui/components/data_grid/data_grid.js";import*as n from"../../ui/components/linkifier/linkifier.js";import*as a from"../../ui/lit-html/lit-html.js";import*as r from"../../core/common/common.js";import*as o from"../../ui/components/issue_counter/issue_counter.js";import*as d from"../../ui/components/adorners/adorners.js";import*as l from"../../core/host/host.js";import*as u from"../../ui/components/icon_button/icon_button.js";import*as c from"../../ui/components/markdown_view/markdown_view.js";import*as p from"../network/forward/forward.js";import*as h from"./components/components.js";import*as g from"../../core/root/root.js";import*as f from"../../core/platform/platform.js";import*as m from"../../core/sdk/sdk.js";import*as C from"../../models/logs/logs.js";import*as I from"../../ui/legacy/components/utils/utils.js";import*as w from"../../ui/components/request_link_icon/request_link_icon.js";const y=new CSSStyleSheet;y.replaceSync(".csp-violations-pane{overflow:hidden}.csp-violations-toolbar{border-bottom:var(--color-details-hairline)}\n/*# sourceURL=cspViolationsView.css */\n");const b={genericMenuLabel:"Menu"},v=t.i18n.registerUIStrings("panels/issues/ComboBoxOfCheckBoxes.ts",b),R=t.i18n.getLocalizedString.bind(void 0,v);class k extends s.Toolbar.ToolbarButton{#e=new Array;#t=new Array;#s=()=>{};constructor(e){super(e),this.turnIntoSelect(),this.addEventListener(s.Toolbar.ToolbarButton.Events.Click,this.#i.bind(this)),s.ARIAUtils.markAsMenuButton(this.element)}addOption(e,t,s){this.#e.push({title:e,value:t,default:s,enabled:s})}setOptionEnabled(e,t){const s=this.#e[e];s&&(s.enabled=t,this.#s())}addHeader(e,t){this.#t.push({title:e,callback:t})}setOnOptionClicked(e){this.#s=e}getOptions(){return this.#e}async#i({data:e}){const t=new s.ContextMenu.ContextMenu(e,{useSoftMenu:!0,x:this.element.getBoundingClientRect().left,y:this.element.getBoundingClientRect().top+this.element.offsetHeight});for(const{title:e,callback:s}of this.#t)t.headerSection().appendItem(e,(()=>s()));for(const[e,{title:s,enabled:i}]of this.#e.entries())t.defaultSection().appendCheckboxItem(s,(()=>{this.setOptionEnabled(e,!i)}),i);t.setContextMenuLabel(this.title??R(b.genericMenuLabel)),await t.show(),t.markAsMenuItemCheckBox()}}const x=new CSSStyleSheet;x.replaceSync("\n/*# sourceURL=cspViolationsListView.css */\n");class S extends s.Widget.VBox{#n=new i.DataGridController.DataGridController;#a=new Set;#r=new Map;constructor(){super(!0),this.#n.data={columns:[{id:"sourceCode",title:"Source Code",sortable:!1,widthWeighting:1,visible:!0,hideable:!1},{id:"violatedDirective",title:"Violated Directive",sortable:!1,widthWeighting:1,visible:!0,hideable:!1},{id:"category",title:"Category",sortable:!1,widthWeighting:1,visible:!0,hideable:!1},{id:"status",title:"Status",sortable:!1,widthWeighting:1,visible:!0,hideable:!1}],rows:[]},this.contentElement.appendChild(this.#n)}updateTextFilter(e){0===e.length?this.#n.data={...this.#n.data,filters:[]}:this.#n.data={...this.#n.data,filters:[{text:e,key:void 0,regex:void 0,negative:!1}]}}updateCategoryFilter(e){this.#a=e;const t=[];for(const[e,s]of this.#r.entries())this.#o(e)&&t.push(s);this.#n.data={...this.#n.data,rows:t}}#o(e){return this.#a.has(e.code())||0===this.#a.size}addIssue(t){const s=e.Issue.toZeroBasedLocation(t.details().sourceCodeLocation);if(!s)return;const i=t.details().isReportOnly?"report-only":"blocked",r=this.#d(t.code()),o={cells:[{columnId:"sourceCode",value:s.url,renderer:()=>a.html`<${n.Linkifier.Linkifier.litTagName} .data="${s}"></${n.Linkifier.Linkifier.litTagName}>`},{columnId:"violatedDirective",value:t.details().violatedDirective},{columnId:"category",value:r},{columnId:"status",value:i}]};this.#r.set(t,o),this.#o(t)&&(this.#n.data.rows.push(o),this.#n.data={...this.#n.data})}clearIssues(){this.#r.clear(),this.#n.data={...this.#n.data,rows:[]}}#d(t){return t===e.ContentSecurityPolicyIssue.inlineViolationCode?"Inline Violation":t===e.ContentSecurityPolicyIssue.urlViolationCode?"URL Violation":t===e.ContentSecurityPolicyIssue.evalViolationCode?"Eval Violation":t===e.ContentSecurityPolicyIssue.trustedTypesSinkViolationCode?"Sink Violation":t===e.ContentSecurityPolicyIssue.trustedTypesPolicyViolationCode?"Policy Violation":"unknown"}wasShown(){super.wasShown(),this.registerCSSFiles([x])}}const T={filter:"Filter"},A=t.i18n.registerUIStrings("panels/issues/CSPViolationsView.ts",T),E=t.i18n.getLocalizedString.bind(void 0,A);let L;class M extends s.Widget.VBox{#l=new S;#u=e.IssuesManager.IssuesManager.instance();constructor(){super(!0),this.contentElement.classList.add("csp-violations-pane");const t=new s.Toolbar.Toolbar("csp-violations-toolbar",this.contentElement),i=new s.Toolbar.ToolbarInput(E(T.filter),"",1,.2,"");i.addEventListener(s.Toolbar.ToolbarInput.Event.TextChanged,(()=>{this.#l.updateTextFilter(i.value())})),t.appendToolbarItem(i);const n=new k("Categories");n.setText("Categories"),n.addOption("Trusted Type Policy",e.ContentSecurityPolicyIssue.trustedTypesPolicyViolationCode,!0),n.addOption("Trusted Type Sink",e.ContentSecurityPolicyIssue.trustedTypesSinkViolationCode,!0),n.addOption("CSP Inline",e.ContentSecurityPolicyIssue.inlineViolationCode,!0),n.addOption("CSP Eval",e.ContentSecurityPolicyIssue.evalViolationCode,!0),n.addOption("CSP URL",e.ContentSecurityPolicyIssue.urlViolationCode,!0),n.addHeader("Reset",(()=>{n.getOptions().forEach(((e,t)=>n.setOptionEnabled(t,e.default)))})),n.setOnOptionClicked((()=>{const e=new Set(n.getOptions().filter((e=>e.enabled)).map((e=>e.value)));this.#l.updateCategoryFilter(e)})),t.appendToolbarItem(n),this.#l.show(this.contentElement),this.#u.addEventListener("IssueAdded",this.#c,this),this.#u.addEventListener("FullUpdateRequired",this.#p,this),this.#h()}static instance(e={forceNew:null}){const{forceNew:t}=e;return L&&!t||(L=new M),L}#c(t){const{issue:s}=t.data;s instanceof e.ContentSecurityPolicyIssue.ContentSecurityPolicyIssue&&this.#l.addIssue(s)}#p(){this.#l.clearIssues(),this.#h()}#h(){for(const t of this.#u.issues())t instanceof e.ContentSecurityPolicyIssue.ContentSecurityPolicyIssue&&this.#l.addIssue(t)}wasShown(){super.wasShown(),this.registerCSSFiles([y])}}var P=Object.freeze({__proto__:null,CSPViolationsView:M});class D extends e.Issue.Issue{#g=new Map;#f=new Map;#m=new Map;#C=new Map;#I=new Set;#w=new Map;#y=new Set;#b=new Set;#v=new Set;#R=new Set;#k=e.Issue.IssueKind.Improvement;#x=new Set;#S=new Set;#T=new Set;#A=new Set;#E=new Set;#L=new Set;#M;#P=0;#D;constructor(e,t){super(e),this.#D=t}primaryKey(){throw new Error("This should never be called")}aggregationKey(){return this.#D}getBlockedByResponseDetails(){return this.#w.values()}cookies(){return Array.from(this.#g.values()).map((e=>e.cookie))}getRawCookieLines(){return this.#f.values()}sources(){return this.#C.values()}getBounceTrackingSites(){return this.#y.values()}cookiesWithRequestIndicator(){return this.#g.values()}getHeavyAdIssues(){return this.#I}getMixedContentIssues(){return this.#S}getCorsIssues(){return this.#b}getCspIssues(){return this.#v}getDeprecationIssues(){return this.#R}getLowContrastIssues(){return this.#x}requests(){return this.#m.values()}getSharedArrayBufferIssues(){return this.#T}getQuirksModeIssues(){return this.#A}getAttributionReportingIssues(){return this.#E}getGenericIssues(){return this.#L}getDescription(){return this.#M?this.#M.getDescription():null}getCategory(){return this.#M?this.#M.getCategory():e.Issue.IssueCategory.Other}getAggregatedIssuesCount(){return this.#P}#q(e){const{domain:t,path:s,name:i}=e;return`${t};${s};${i}`}addInstance(t){this.#P++,this.#M||(this.#M=t),this.#k=e.Issue.unionIssueKind(this.#k,t.getKind());let s=!1;for(const e of t.requests())s=!0,this.#m.has(e.requestId)||this.#m.set(e.requestId,e);for(const e of t.cookies()){const t=this.#q(e);this.#g.has(t)||this.#g.set(t,{cookie:e,hasRequest:s})}for(const e of t.rawCookieLines())this.#f.has(e)||this.#f.set(e,{rawCookieLine:e,hasRequest:s});for(const e of t.trackingSites())this.#y.has(e)||this.#y.add(e);for(const e of t.sources()){const t=JSON.stringify(e);this.#C.has(t)||this.#C.set(t,e)}t instanceof e.MixedContentIssue.MixedContentIssue&&this.#S.add(t),t instanceof e.HeavyAdIssue.HeavyAdIssue&&this.#I.add(t);for(const e of t.getBlockedByResponseDetails()){const t=JSON.stringify(e,["parentFrame","blockedFrame","requestId","frameId","reason","request"]);this.#w.set(t,e)}t instanceof e.ContentSecurityPolicyIssue.ContentSecurityPolicyIssue&&this.#v.add(t),t instanceof e.DeprecationIssue.DeprecationIssue&&this.#R.add(t),t instanceof e.SharedArrayBufferIssue.SharedArrayBufferIssue&&this.#T.add(t),t instanceof e.LowTextContrastIssue.LowTextContrastIssue&&this.#x.add(t),t instanceof e.CorsIssue.CorsIssue&&this.#b.add(t),t instanceof e.QuirksModeIssue.QuirksModeIssue&&this.#A.add(t),t instanceof e.AttributionReportingIssue.AttributionReportingIssue&&this.#E.add(t),t instanceof e.GenericIssue.GenericIssue&&this.#L.add(t)}getKind(){return this.#k}isHidden(){return this.#M?.isHidden()||!1}setHidden(e){throw new Error("Should not call setHidden on aggregatedIssue")}}class q extends r.ObjectWrapper.ObjectWrapper{issuesManager;#V=new Map;#O=new Map;constructor(e){super(),this.issuesManager=e,this.issuesManager.addEventListener("IssueAdded",this.#c,this),this.issuesManager.addEventListener("FullUpdateRequired",this.#p,this);for(const e of this.issuesManager.issues())this.#U(e)}#c(e){this.#U(e.data.issue)}#p(){this.#V.clear(),this.#O.clear();for(const e of this.issuesManager.issues())this.#U(e);this.dispatchEventToListeners("FullUpdateRequired")}#U(e){const t=e.isHidden()?this.#O:this.#V,s=this.#H(t,e);return this.dispatchEventToListeners("AggregatedIssueUpdated",s),s}#H(e,t){const s=t.code();let i=e.get(s);return i||(i=new D(t.code(),s),e.set(s,i)),i.addInstance(t),i}aggregatedIssues(){return[...this.#V.values(),...this.#O.values()]}hiddenAggregatedIssues(){return this.#O.values()}aggregatedIssueCodes(){return new Set([...this.#V.keys(),...this.#O.keys()])}aggregatedIssueCategories(){const e=new Set;for(const t of this.#V.values())e.add(t.getCategory());return e}aggregatedIssueKinds(){const e=new Set;for(const t of this.#V.values())e.add(t.getKind());return e}numberOfAggregatedIssues(){return this.#V.size}numberOfHiddenAggregatedIssues(){return this.#O.size}keyForIssue(e){return e.code()}}var V=Object.freeze({__proto__:null,AggregatedIssue:D,IssueAggregator:q});const O={hiddenIssues:"Hidden issues",unhideAll:"Unhide all"},U=t.i18n.registerUIStrings("panels/issues/HiddenIssuesRow.ts",O),H=t.i18n.getLocalizedString.bind(void 0,U);class F extends s.TreeOutline.TreeElement{#F;constructor(){super(void 0,!0),this.#F=document.createElement("span"),this.toggleOnClick=!0,this.listItemElement.classList.add("issue-category","hidden-issues"),this.childrenListElement.classList.add("hidden-issues-body"),this.#N()}#N(){const t=s.UIUtils.createTextButton(H(O.unhideAll),(()=>e.IssuesManager.IssuesManager.instance().unhideAllIssues()),"unhide-all-issues-button"),i=new d.Adorner.Adorner;i.data={name:"countWrapper",content:this.#F},i.classList.add("aggregated-issues-count"),this.#F.textContent="0";const n=document.createElement("div"),a=document.createElement("div");n.classList.add("header"),a.classList.add("title"),a.textContent=H(O.hiddenIssues),n.appendChild(i),n.appendChild(a),n.appendChild(t),this.listItemElement.appendChild(n)}update(e){this.#F.textContent=`${e}`}}const N=new CSSStyleSheet;N.replaceSync(".issues-pane{overflow:hidden}.issues-pane-no-issues{align-items:center;background-color:var(--color-background);display:flex;flex:1 1 auto;font-size:18px;justify-content:center;padding:30px}.issues-toolbar-container{display:flex;flex:none}.issues-toolbar-container > .toolbar{background-color:var(--color-background-elevation-1);border-bottom:1px solid var(--color-details-hairline)}.issues-toolbar-left{flex:1 1 auto}.issues-toolbar-right{padding-right:6px}\n/*# sourceURL=issuesPane.css */\n");const B=new CSSStyleSheet;B.replaceSync(':host,\n.issues{padding:0;overflow:auto}.issues{--issue-indent:8px}.issues li{white-space:normal;align-items:flex-start}.issues .always-parent::before{display:none}.issues li.parent::before{margin-top:8px}.issues .affected-resources li.parent::before{margin-top:3px;margin-right:0}.issue-category,\n.issue-kind,\n.issue{padding:0 8px;padding-left:var(--issue-indent);overflow:hidden;flex:none;transition:background-color 200ms;border:1px solid var(--color-details-hairline-light);border-width:0 0 1px}.issue-category.hidden-issues.parent.expanded,\n.issue-kind.parent.expanded{border-width:0 0 1px;background-color:var(--color-background-elevation-1)}.issue-category + .children .issue,\n.issue.expanded{background:var(--color-background)}.issue.expanded{border-width:0}.issue.selected,\n.issue.expanded.selected{background-color:var(--legacy-focus-bg-color)}.unhide-all-issues-button{margin:0;height:20px}p{margin-block-start:2px;margin-block-end:2px}.tree-outline-disclosure:not(.tree-outline-disclosure-hide-overflow) .tree-outline.hide-selection-when-blurred .issue-category.selected:focus-visible,\n.tree-outline-disclosure:not(.tree-outline-disclosure-hide-overflow) .tree-outline.hide-selection-when-blurred .issue-kind.selected:focus-visible,\n.tree-outline-disclosure:not(.tree-outline-disclosure-hide-overflow) .tree-outline.hide-selection-when-blurred .issue.selected:focus-visible{width:auto;padding-right:8px}.header{display:flex;flex-direction:row;align-items:flex-start;padding:4px 0;cursor:pointer;width:100%}.header devtools-hide-issues-menu{visibility:hidden}.header:hover devtools-hide-issues-menu{visibility:visible}.header devtools-hide-issues-menu.has-context-menu-opened{visibility:visible}.title{flex:1;font-size:14px;color:var(--color-text-primary);font-weight:normal;user-select:text;padding-top:2px}.issue.expanded .title{font-weight:450}.body.children{border-bottom:1px solid var(--color-details-hairline-light);padding:6px 0;position:relative;padding-left:calc(var(--issue-indent) + 43px);padding-bottom:26px;padding-right:8px}.issue-category + .children,\n.issue-kind + .children{--issue-indent:24px;padding-left:0}.body::before{content:"";display:block;position:absolute;left:calc(var(--issue-indent) + 23px);top:0;bottom:20px;width:2px}.issue-kind-breaking-change.body::before{border-left:2px solid var(--issue-color-yellow)}.issue-kind-page-error.body::before{border-left:2px solid var(--issue-color-red)}.issue-kind-improvement.body::before{border-left:2px solid var(--issue-color-blue)}devtools-icon.leading-issue-icon{margin:1px 0 -1px 7px}.message{line-height:20px;font-size:14px;color:var(--color-text-secondary);margin-bottom:4px;user-select:text}.message p{margin-bottom:16px}.message li{margin-top:8px}.message code{color:var(--color-text-primary);font-size:12px;user-select:text;cursor:text;background:var(--color-background-elevation-1)}.separator::before{content:"·";padding-left:1ex;padding-right:1ex}.link{font-size:14px;color:var(--color-link)}.link-wrapper{margin-top:15px;user-select:text}.affected-resources-label,\n.resolutions-label{margin-top:5px;font-size:10px;font-weight:500;letter-spacing:0.06em;text-transform:uppercase;color:var(--color-text-primary);display:inline-block}.link-list{list-style-type:none;list-style-position:inside;padding-inline-start:0}.resolutions-list{list-style-type:none;list-style-position:inside;padding-inline-start:0}.link-list li::before{content:none;-webkit-mask-image:none}.resolutions-list li::before{content:"→";-webkit-mask-image:none;padding-right:5px;position:relative;top:-1px}.resolutions-list li{display:list-item}ul > li.plain-enum{display:list-item}ul > li.plain-enum::before{content:"";padding:0;margin:0;max-width:0}.affected-resources-label + .affected-resources{padding:3px 0 0;position:relative;user-select:text}.affected-resource-label{font-size:14px;line-height:20px;color:var(--color-text-primary);position:relative;cursor:pointer}.affected-resource-cookie{font-size:14px;line-height:20px;border:0;border-collapse:collapse}.affected-resource-element{font-size:14px;line-height:20px;color:var(--color-link);border:0;border-collapse:collapse}.affected-resource-row{font-size:14px;line-height:20px;border:0;border-collapse:collapse;vertical-align:top}.affected-resource-mixed-content{font-size:14px;line-height:20px;border:0;border-collapse:collapse}.affected-resource-heavy-ad{font-size:14px;line-height:20px;border:0;border-collapse:collapse}.affected-resource-request{font-size:14px;line-height:20px;border:0;border-collapse:collapse}.affected-resource-source{font-size:14px;line-height:20px;color:var(--color-link);border:0;border-collapse:collapse}.affected-resource-list{border-spacing:10px 0;margin-left:-12px}.affected-resource-header{font-size:12px;color:var(--color-text-primary);padding-left:2px}.code-example{font-family:var(--monospace-font-family);font-size:var(--monospace-font-size)}.affected-resource-blocked-status{color:var(--issue-color-red)}.affected-resource-report-only-status{color:var(--issue-color-yellow)}.affected-resource-cookie-info{color:var(--color-text-secondary);padding:2px;text-align:right}.affected-resource-cookie-info-header{text-align:right}.affected-resource-mixed-content-info{color:var(--color-text-secondary);padding:2px}.affected-resource-heavy-ad-info{color:var(--color-text-secondary);padding:2px}.affected-resource-heavy-ad-info-frame{display:flex;align-items:center;color:var(--color-text-secondary);padding:2px}.affected-resource-cell{color:var(--color-text-secondary);padding:2px}.affected-resource-cell.link{color:var(--color-link)}.affected-resource-cell span.icon{margin-right:0.5ex;vertical-align:sub}.affected-resources > .parent{margin-top:0;padding:2px 5px 0}.affected-resources > .parent.expanded{background:var(--color-background-elevation-0)}.affected-resources > .children.expanded{background:var(--color-background-elevation-0);padding:6px 0 9px 5px;margin-bottom:10px}.aggregated-issues-count{padding:3px 7px 0}.affected-resource-directive-info-header{text-align:left}.affected-resource-directive{font-size:14px;line-height:20px;border:0;border-collapse:collapse}.affected-resource-directive-info{color:var(--color-text-secondary);padding:2px;text-align:left}.devtools-link{padding-top:4px}devtools-icon.link-icon{vertical-align:sub;margin-right:0.5ch}devtools-icon.elements-panel,\ndevtools-icon.network-panel{margin-right:0.5ex;vertical-align:baseline;height:14px}@media (forced-colors: active){.title{color:ButtonText}.tree-outline:not(.hide-selection-when-blurred) .selected .header .title,\n  .tree-outline.hide-selection-when-blurred .selected:focus-visible .header .title{color:HighlightText}}\n/*# sourceURL=issuesTree.css */\n');const K={unknown:"unknown",clickToRevealTheFramesDomNodeIn:"Click to reveal the frame's DOM node in the Elements panel",unavailable:"unavailable"},W=t.i18n.registerUIStrings("panels/issues/AffectedResourcesView.ts",K),z=t.i18n.getLocalizedString.bind(void 0,W);class _ extends s.TreeOutline.TreeElement{#B;issue;affectedResourcesCountElement;affectedResources;#K;#W;#z;requestResolver;constructor(e,t){super(),this.#B=e,this.issue=t,this.toggleOnClick=!0,this.affectedResourcesCountElement=this.createAffectedResourcesCounter(),this.affectedResources=this.createAffectedResources(),this.#K=0,this.requestResolver=new C.RequestResolver.RequestResolver,this.#W=[],this.#z=new Set}setIssue(e){this.issue=e}createAffectedResourcesCounter(){const e=document.createElement("div");return e.classList.add("affected-resource-label"),this.listItemElement.appendChild(e),e}createAffectedResources(){const e=new s.TreeOutline.TreeElement,t=document.createElement("table");return t.classList.add("affected-resource-list"),e.listItemElement.appendChild(t),this.appendChild(e),t}updateAffectedResourceCount(e){this.#K=e,this.affectedResourcesCountElement.textContent=this.getResourceNameWithCount(e),this.hidden=0===this.#K,this.#B.updateAffectedResourceVisibility()}isEmpty(){return 0===this.#K}clear(){this.affectedResources.textContent="",this.requestResolver.clear()}expandIfOneResource(){1===this.#K&&this.expand()}#_(e){const t=m.FrameManager.FrameManager.instance().getFrame(e);if(!(t&&t.url||(this.#z.add(e),this.#W.length))){const e=m.FrameManager.FrameManager.instance().addEventListener(m.FrameManager.Events.FrameAddedToTarget,this.#j,this),t=m.FrameManager.FrameManager.instance().addEventListener(m.FrameManager.Events.FrameNavigated,this.#j,this);this.#W=[e,t]}return t}#j(e){const t=e.data.frame;if(!t.url)return;const s=this.#z.delete(t.id);0===this.#z.size&&this.#W.length&&(r.EventTarget.removeEventListeners(this.#W),this.#W=[]),s&&this.update()}createFrameCell(e,t){const s=this.#_(e),i=s&&(s.unreachableUrl()||s.url)||z(K.unknown),n=document.createElement("td");if(n.classList.add("affected-resource-cell"),s){const s=new u.Icon.Icon;s.data={iconName:"code-circle",color:"var(--icon-link)",width:"16px",height:"16px"},s.classList.add("link","elements-panel"),s.onclick=async()=>{l.userMetrics.issuesPanelResourceOpened(t,"Element");const s=m.FrameManager.FrameManager.instance().getFrame(e);if(s){const e=await s.getOwnerDOMNodeOrDocument();e&&r.Revealer.reveal(e)}},s.title=z(K.clickToRevealTheFramesDomNodeIn),n.appendChild(s)}return n.appendChild(document.createTextNode(i)),n.onmouseenter=()=>{const t=m.FrameManager.FrameManager.instance().getFrame(e);t&&t.highlight()},n.onmouseleave=()=>m.OverlayModel.OverlayModel.hideDOMNodeHighlight(),n}createRequestCell(e,t={}){const s=document.createElement("td");s.classList.add("affected-resource-cell");const i=new w.RequestLinkIcon.RequestLinkIcon;return i.data={...t,affectedRequest:e,requestResolver:this.requestResolver,displayURL:!0},s.appendChild(i),s}async createElementCell({backendNodeId:e,nodeName:t,target:s},i){if(!s){const e=document.createElement("td");return e.textContent=t||z(K.unavailable),e}function n(){l.userMetrics.issuesPanelResourceOpened(i,"Element")}const a=new m.DOMModel.DeferredDOMNode(s,e),o=await r.Linkifier.Linkifier.linkify(a);o.textContent=t,o.addEventListener("click",(()=>n())),o.addEventListener("keydown",(e=>{"Enter"===e.key&&n()}));const d=document.createElement("td");return d.classList.add("affected-resource-element","devtools-link"),d.appendChild(o),d}appendSourceLocation(e,t,s){const i=document.createElement("td");if(i.classList.add("affected-source-location"),t){const e=40,n=new I.Linkifier.Linkifier(e).linkifyScriptLocation(s||null,t.scriptId||null,t.url,t.lineNumber,{columnNumber:t.columnNumber,inlineFrameIndex:0});i.appendChild(n)}e.appendChild(i)}appendColumnTitle(e,t,s=null){const i=document.createElement("td");i.classList.add("affected-resource-header"),s&&i.classList.add(s),i.textContent=t,e.appendChild(i)}createIssueDetailCell(e,t=null){const s=document.createElement("td");return s.textContent=e,t&&s.classList.add(t),s}appendIssueDetailCell(e,t,s=null){const i=this.createIssueDetailCell(t,s);return e.appendChild(i),i}}const j={nDirectives:"{n, plural, =1 {# directive} other {# directives}}",reportonly:"report-only",blocked:"blocked",clickToRevealTheViolatingDomNode:"Click to reveal the violating DOM node in the Elements panel",directiveC:"Directive",element:"Element",sourceLocation:"Source Location",status:"Status",resourceC:"Resource"},G=t.i18n.registerUIStrings("panels/issues/AffectedDirectivesView.ts",j),$=t.i18n.getLocalizedString.bind(void 0,G);class Q extends _{#G(e,t){const s=document.createElement("td");t?(s.classList.add("affected-resource-report-only-status"),s.textContent=$(j.reportonly)):(s.classList.add("affected-resource-blocked-status"),s.textContent=$(j.blocked)),e.appendChild(s)}getResourceNameWithCount(e){return $(j.nDirectives,{n:e})}#$(e,t){const s=document.createElement("td");s.textContent=t,e.appendChild(s)}#Q(e,t){const s=document.createElement("td");s.classList.add("affected-resource-directive-info"),s.textContent=t,e.appendChild(s)}#Z(e,t,s){const i=new h.ElementsPanelLink.ElementsPanelLink;if(t){const e=t;i.title=$(j.clickToRevealTheViolatingDomNode);const n=()=>{const t=s.getTargetIfNotDisposed();if(t){l.userMetrics.issuesPanelResourceOpened(this.issue.getCategory(),"Element");const s=new m.DOMModel.DeferredDOMNode(t,e);r.Revealer.reveal(s)}},a=()=>{const t=s.getTargetIfNotDisposed();if(t){const s=new m.DOMModel.DeferredDOMNode(t,e);s&&s.highlight()}},o=()=>{m.OverlayModel.OverlayModel.hideDOMNodeHighlight()};i.data={onElementRevealIconClick:n,onElementRevealIconMouseEnter:a,onElementRevealIconMouseLeave:o}}const n=document.createElement("td");n.classList.add("affected-resource-csp-info-node"),n.appendChild(i),e.appendChild(n)}#J(t){const s=document.createElement("tr");if(this.issue.code()===e.ContentSecurityPolicyIssue.inlineViolationCode)this.appendColumnTitle(s,$(j.directiveC)),this.appendColumnTitle(s,$(j.element)),this.appendColumnTitle(s,$(j.sourceLocation)),this.appendColumnTitle(s,$(j.status));else if(this.issue.code()===e.ContentSecurityPolicyIssue.urlViolationCode)this.appendColumnTitle(s,$(j.resourceC),"affected-resource-directive-info-header"),this.appendColumnTitle(s,$(j.status)),this.appendColumnTitle(s,$(j.directiveC)),this.appendColumnTitle(s,$(j.sourceLocation));else if(this.issue.code()===e.ContentSecurityPolicyIssue.evalViolationCode)this.appendColumnTitle(s,$(j.sourceLocation)),this.appendColumnTitle(s,$(j.directiveC)),this.appendColumnTitle(s,$(j.status));else if(this.issue.code()===e.ContentSecurityPolicyIssue.trustedTypesSinkViolationCode)this.appendColumnTitle(s,$(j.sourceLocation)),this.appendColumnTitle(s,$(j.status));else{if(this.issue.code()!==e.ContentSecurityPolicyIssue.trustedTypesPolicyViolationCode)return void this.updateAffectedResourceCount(0);this.appendColumnTitle(s,$(j.sourceLocation)),this.appendColumnTitle(s,$(j.directiveC)),this.appendColumnTitle(s,$(j.status))}this.affectedResources.appendChild(s);let i=0;for(const e of t)i++,this.#X(e);this.updateAffectedResourceCount(i)}#X(t){const s=document.createElement("tr");s.classList.add("affected-resource-directive");const i=t.details(),n=e.Issue.toZeroBasedLocation(i.sourceCodeLocation),a=t.model(),r=t.model()?.getTargetIfNotDisposed();if(this.issue.code()===e.ContentSecurityPolicyIssue.inlineViolationCode&&a)this.#$(s,i.violatedDirective),this.#Z(s,i.violatingNodeId,a),this.appendSourceLocation(s,n,r),this.#G(s,i.isReportOnly);else if(this.issue.code()===e.ContentSecurityPolicyIssue.urlViolationCode){const e=i.blockedURL?i.blockedURL:f.DevToolsPath.EmptyUrlString;this.#Q(s,e),this.#G(s,i.isReportOnly),this.#$(s,i.violatedDirective),this.appendSourceLocation(s,n,r)}else if(this.issue.code()===e.ContentSecurityPolicyIssue.evalViolationCode)this.appendSourceLocation(s,n,r),this.#$(s,i.violatedDirective),this.#G(s,i.isReportOnly);else if(this.issue.code()===e.ContentSecurityPolicyIssue.trustedTypesSinkViolationCode)this.appendSourceLocation(s,n,r),this.#G(s,i.isReportOnly);else{if(this.issue.code()!==e.ContentSecurityPolicyIssue.trustedTypesPolicyViolationCode)return;this.appendSourceLocation(s,n,r),this.#$(s,i.violatedDirective),this.#G(s,i.isReportOnly)}this.affectedResources.appendChild(s)}update(){this.clear(),this.#J(this.issue.getCspIssues())}}const Z={nRequests:"{n, plural, =1 {# request} other {# requests}}",requestC:"Request",parentFrame:"Parent Frame",blockedResource:"Blocked Resource"},J=t.i18n.registerUIStrings("panels/issues/AffectedBlockedByResponseView.ts",Z),X=t.i18n.getLocalizedString.bind(void 0,J);class Y extends _{#Y(e){const t=document.createElement("tr");this.appendColumnTitle(t,X(Z.requestC)),this.appendColumnTitle(t,X(Z.parentFrame)),this.appendColumnTitle(t,X(Z.blockedResource)),this.affectedResources.appendChild(t);let s=0;for(const t of e)this.#ee(t),s++;this.updateAffectedResourceCount(s)}getResourceNameWithCount(e){return X(Z.nRequests,{n:e})}#ee(t){const s=document.createElement("tr");s.classList.add("affected-resource-row");const i=this.createRequestCell(t.request,{additionalOnClickAction(){l.userMetrics.issuesPanelResourceOpened(e.Issue.IssueCategory.CrossOriginEmbedderPolicy,"Request")}});if(s.appendChild(i),t.parentFrame){const e=this.createFrameCell(t.parentFrame.frameId,this.issue.getCategory());s.appendChild(e)}else s.appendChild(document.createElement("td"));if(t.blockedFrame){const e=this.createFrameCell(t.blockedFrame.frameId,this.issue.getCategory());s.appendChild(e)}else s.appendChild(document.createElement("td"));this.affectedResources.appendChild(s)}update(){this.clear(),this.#Y(this.issue.getBlockedByResponseDetails())}}const ee={nCookies:"{n, plural, =1 {# cookie} other {# cookies}}",name:"Name",domain:"Domain",path:"Path",nRawCookieLines:"{n, plural, =1 {1 Raw `Set-Cookie` header} other {# Raw `Set-Cookie` headers}}",filterSetCookieTitle:"Show network requests that include this `Set-Cookie` header in the network panel"},te=t.i18n.registerUIStrings("panels/issues/AffectedCookiesView.ts",ee),se=t.i18n.getLocalizedString.bind(void 0,te);class ie extends _{getResourceNameWithCount(e){return se(ee.nCookies,{n:e})}#te(e){const t=document.createElement("tr");this.appendColumnTitle(t,se(ee.name)),this.appendColumnTitle(t,se(ee.domain)+" & "+se(ee.path),"affected-resource-cookie-info-header"),this.affectedResources.appendChild(t);let s=0;for(const t of e)s++,this.#se(t.cookie,t.hasRequest);this.updateAffectedResourceCount(s)}#se(e,t){const i=document.createElement("tr");i.classList.add("affected-resource-cookie");const n=document.createElement("td");t?n.appendChild(s.UIUtils.createTextButton(e.name,(()=>{l.userMetrics.issuesPanelResourceOpened(this.issue.getCategory(),"Cookie"),r.Revealer.reveal(p.UIFilter.UIRequestFilter.filters([{filterType:p.UIFilter.FilterType.CookieDomain,filterValue:e.domain},{filterType:p.UIFilter.FilterType.CookieName,filterValue:e.name},{filterType:p.UIFilter.FilterType.CookiePath,filterValue:e.path}]))}),"link-style devtools-link")):n.textContent=e.name,i.appendChild(n),this.appendIssueDetailCell(i,`${e.domain}${e.path}`,"affected-resource-cookie-info"),this.affectedResources.appendChild(i)}update(){this.clear(),this.#te(this.issue.cookiesWithRequestIndicator())}}class ne extends _{getResourceNameWithCount(e){return se(ee.nRawCookieLines,{n:e})}update(){this.clear();const e=this.issue.getRawCookieLines();let t=0;for(const i of e){const e=document.createElement("tr");if(e.classList.add("affected-resource-directive"),i.hasRequest){const t=document.createElement("td"),n=s.UIUtils.createTextButton(i.rawCookieLine,(()=>{r.Revealer.reveal(p.UIFilter.UIRequestFilter.filters([{filterType:p.UIFilter.FilterType.ResponseHeaderValueSetCookie,filterValue:i.rawCookieLine}]))}),"link-style devtools-link");n.title=se(ee.filterSetCookieTitle),t.appendChild(n),e.appendChild(t)}else this.appendIssueDetailCell(e,i.rawCookieLine);this.affectedResources.appendChild(e),t++}this.updateAffectedResourceCount(t)}}const ae={nElements:"{n, plural, =1 {# element} other {# elements}}"},re=t.i18n.registerUIStrings("panels/issues/AffectedElementsView.ts",ae),oe=t.i18n.getLocalizedString.bind(void 0,re);class de extends _{async#ie(e){let t=0;for(const s of e)await this.#ne(s),t++;this.updateAffectedResourceCount(t)}getResourceNameWithCount(e){return oe(ae.nElements,{n:e})}async#ne(e){const t=await this.createElementCell(e,this.issue.getCategory()),s=document.createElement("tr");s.appendChild(t),this.affectedResources.appendChild(s)}update(){this.clear(),this.#ie(this.issue.elements())}}const le={nDocuments:"{n, plural, =1 { document} other { documents}}",documentInTheDOMTree:"Document in the DOM tree",url:"URL",mode:"Mode"},ue=t.i18n.registerUIStrings("panels/issues/AffectedDocumentsInQuirksModeView.ts",le),ce=t.i18n.getLocalizedString.bind(void 0,ue);class pe extends de{#ae=Promise.resolve();update(){this.#ae=this.#ae.then(this.#re.bind(this))}getResourceName(e){return ce(le.nDocuments,{n:e})}async#re(){this.clear(),await this.#oe(this.issue.getQuirksModeIssues())}async#de(e){const t=document.createElement("tr");t.classList.add("affected-resource-quirks-mode");const s=e.details(),i=m.FrameManager.FrameManager.instance().getFrame(s.frameId)?.resourceTreeModel().target()||null;t.appendChild(await this.createElementCell({nodeName:"document",backendNodeId:s.documentNodeId,target:i},e.getCategory())),this.appendIssueDetailCell(t,s.isLimitedQuirksMode?"Limited Quirks Mode":"Quirks Mode"),this.appendIssueDetailCell(t,s.url),this.affectedResources.appendChild(t)}async#oe(e){const t=document.createElement("tr");this.appendColumnTitle(t,ce(le.documentInTheDOMTree)),this.appendColumnTitle(t,ce(le.mode)),this.appendColumnTitle(t,ce(le.url)),this.affectedResources.appendChild(t);let s=0;for(const t of e)s++,await this.#de(t);this.updateAffectedResourceCount(s)}}class he extends de{#ae=Promise.resolve();update(){this.#ae=this.#ae.then(this.#re.bind(this))}async#re(){this.clear(),await this.#le(this.issue.getLowContrastIssues())}async#ue(e){const t=document.createElement("tr");t.classList.add("affected-resource-low-contrast");const s=e.details(),i=e.model()?.target()||null;t.appendChild(await this.createElementCell({nodeName:s.violatingNodeSelector,backendNodeId:s.violatingNodeId,target:i},e.getCategory())),this.appendIssueDetailCell(t,String(f.NumberUtilities.floor(s.contrastRatio,2))),this.appendIssueDetailCell(t,String(s.thresholdAA)),this.appendIssueDetailCell(t,String(s.thresholdAAA)),this.appendIssueDetailCell(t,s.fontSize),this.appendIssueDetailCell(t,s.fontWeight),this.affectedResources.appendChild(t)}async#le(e){const t=document.createElement("tr");this.appendColumnTitle(t,me(ge.element)),this.appendColumnTitle(t,me(ge.contrastRatio)),this.appendColumnTitle(t,me(ge.minimumAA)),this.appendColumnTitle(t,me(ge.minimumAAA)),this.appendColumnTitle(t,me(ge.textSize)),this.appendColumnTitle(t,me(ge.textWeight)),this.affectedResources.appendChild(t);let s=0;for(const t of e)s++,await this.#ue(t);this.updateAffectedResourceCount(s)}}const ge={element:"Element",contrastRatio:"Contrast ratio",minimumAA:"Minimum AA ratio",minimumAAA:"Minimum AAA ratio",textSize:"Text size",textWeight:"Text weight"},fe=t.i18n.registerUIStrings("panels/issues/AffectedElementsWithLowContrastView.ts",ge),me=t.i18n.getLocalizedString.bind(void 0,fe),Ce={nResources:"{n, plural, =1 {# resource} other {# resources}}",limitExceeded:"Limit exceeded",resolutionStatus:"Resolution Status",frameUrl:"Frame URL",removed:"Removed",warned:"Warned",cpuPeakLimit:"CPU peak limit",cpuTotalLimit:"CPU total limit",networkLimit:"Network limit"},Ie=t.i18n.registerUIStrings("panels/issues/AffectedHeavyAdView.ts",Ce),we=t.i18n.getLocalizedString.bind(void 0,Ie);class ye extends _{#ce(e){const t=document.createElement("tr");this.appendColumnTitle(t,we(Ce.limitExceeded)),this.appendColumnTitle(t,we(Ce.resolutionStatus)),this.appendColumnTitle(t,we(Ce.frameUrl)),this.affectedResources.appendChild(t);let s=0;for(const t of e)this.#pe(t.details()),s++;this.updateAffectedResourceCount(s)}getResourceNameWithCount(e){return we(Ce.nResources,{n:e})}#he(e){switch(e){case"HeavyAdBlocked":return we(Ce.removed);case"HeavyAdWarning":return we(Ce.warned)}return""}#ge(e){switch(e){case"CpuPeakLimit":return we(Ce.cpuPeakLimit);case"CpuTotalLimit":return we(Ce.cpuTotalLimit);case"NetworkTotalLimit":return we(Ce.networkLimit)}return""}#pe(e){const t=document.createElement("tr");t.classList.add("affected-resource-heavy-ad");const s=document.createElement("td");s.classList.add("affected-resource-heavy-ad-info"),s.textContent=this.#ge(e.reason),t.appendChild(s);const i=document.createElement("td");i.classList.add("affected-resource-heavy-ad-info"),i.textContent=this.#he(e.resolution),t.appendChild(i);const n=e.frame.frameId,a=this.createFrameCell(n,this.issue.getCategory());t.appendChild(a),this.affectedResources.appendChild(t)}update(){this.clear(),this.#ce(this.issue.getHeavyAdIssues())}}const be={nViolations:"{n, plural, =1 {# violation} other {# violations}}",warning:"warning",blocked:"blocked",instantiation:"Instantiation",aSharedarraybufferWas:"A `SharedArrayBuffer` was instantiated in a context that is not cross-origin isolated",transfer:"Transfer",sharedarraybufferWasTransferedTo:"`SharedArrayBuffer` was transfered to a context that is not cross-origin isolated",sourceLocation:"Source Location",trigger:"Trigger",status:"Status"},ve=t.i18n.registerUIStrings("panels/issues/AffectedSharedArrayBufferIssueDetailsView.ts",be),Re=t.i18n.getLocalizedString.bind(void 0,ve);class ke extends _{getResourceNameWithCount(e){return Re(be.nViolations,{n:e})}#G(e,t){const s=document.createElement("td");t?(s.classList.add("affected-resource-report-only-status"),s.textContent=Re(be.warning)):(s.classList.add("affected-resource-blocked-status"),s.textContent=Re(be.blocked)),e.appendChild(s)}#fe(e,t){const s=document.createElement("td");switch(t){case"CreationIssue":s.textContent=Re(be.instantiation),s.title=Re(be.aSharedarraybufferWas);break;case"TransferIssue":s.textContent=Re(be.transfer),s.title=Re(be.sharedarraybufferWasTransferedTo)}e.appendChild(s)}#Y(e){const t=document.createElement("tr");this.appendColumnTitle(t,Re(be.sourceLocation)),this.appendColumnTitle(t,Re(be.trigger)),this.appendColumnTitle(t,Re(be.status)),this.affectedResources.appendChild(t);let s=0;for(const t of e)s++,this.#ee(t);this.updateAffectedResourceCount(s)}#ee(t){const s=document.createElement("tr");s.classList.add("affected-resource-directive");const i=t.details(),n=e.Issue.toZeroBasedLocation(i.sourceCodeLocation);this.appendSourceLocation(s,n,t.model()?.getTargetIfNotDisposed()),this.#fe(s,i.type),this.#G(s,i.isWarning),this.affectedResources.appendChild(s)}update(){this.clear(),this.#Y(this.issue.getSharedArrayBufferIssues())}}const xe={nSources:"{n, plural, =1 {# source} other {# sources}}"},Se=t.i18n.registerUIStrings("panels/issues/AffectedSourcesView.ts",xe),Te=t.i18n.getLocalizedString.bind(void 0,Se);class Ae extends _{#me(e){let t=0;for(const s of e)this.#Ce(s),t++;this.updateAffectedResourceCount(t)}getResourceNameWithCount(e){return Te(xe.nSources,{n:e})}#Ce({url:e,lineNumber:t,columnNumber:s}){const i=document.createElement("td"),n={columnNumber:s,lineNumber:t,tabStop:!0,showColumnNumber:!1,inlineFrameIndex:0},a=I.Linkifier.Linkifier.linkifyURL(e,n);i.appendChild(a);const r=document.createElement("tr");r.classList.add("affected-resource-source"),r.appendChild(i),this.affectedResources.appendChild(r)}update(){this.clear(),this.#me(this.issue.sources())}}const Ee={nTrackingSites:"{n, plural, =1 {1 potentially tracking website} other {# potentially tracking websites}}"},Le=t.i18n.registerUIStrings("panels/issues/AffectedTrackingSitesView.ts",Ee),Me=t.i18n.getLocalizedString.bind(void 0,Le);class Pe extends _{getResourceNameWithCount(e){return Me(Ee.nTrackingSites,{n:e})}update(){this.clear();const e=this.issue.getBounceTrackingSites();let t=0;for(const s of e){const e=document.createElement("tr");e.classList.add("affected-resource-directive"),this.appendIssueDetailCell(e,s),this.affectedResources.appendChild(e),t++}this.updateAffectedResourceCount(t)}}const De={nRequests:"{n, plural, =1 {# request} other {# requests}}",warning:"warning",blocked:"blocked",status:"Status",request:"Request",resourceAddressSpace:"Resource Address",initiatorAddressSpace:"Initiator Address",secure:"secure",insecure:"insecure",initiatorContext:"Initiator Context",preflightRequestIfProblematic:"Preflight Request (if problematic)",preflightRequest:"Preflight Request",header:"Header",problem:"Problem",invalidValue:"Invalid Value (if available)",problemMissingHeader:"Missing Header",problemMultipleValues:"Multiple Values",problemInvalidValue:"Invalid Value",preflightDisallowedRedirect:"Response to preflight was a redirect",preflightInvalidStatus:"HTTP status of preflight request didn't indicate success",allowedOrigin:"Allowed Origin (from header)",allowCredentialsValueFromHeader:"`Access-Control-Allow-Credentials` Header Value",disallowedRequestMethod:"Disallowed Request Method",disallowedRequestHeader:"Disallowed Request Header",sourceLocation:"Source Location",unsupportedScheme:"Unsupported Scheme",failedRequest:"Failed Request"},qe=t.i18n.registerUIStrings("panels/issues/CorsIssueDetailsView.ts",De),Ve=t.i18n.getLocalizedString.bind(void 0,qe);class Oe extends _{constructor(e,t){super(e,t),this.affectedResourcesCountElement.classList.add("cors-issue-affected-resource-label")}#G(e,t){const s=document.createElement("td");t?(s.classList.add("affected-resource-report-only-status"),s.textContent=Ve(De.warning)):(s.classList.add("affected-resource-blocked-status"),s.textContent=Ve(De.blocked)),e.appendChild(s)}getResourceNameWithCount(e){return Ve(De.nRequests,{n:e})}#Y(t,s){const i=document.createElement("tr");switch(this.appendColumnTitle(i,Ve(De.request)),this.appendColumnTitle(i,Ve(De.status)),t){case e.CorsIssue.IssueCode.InvalidHeaderValues:this.appendColumnTitle(i,Ve(De.preflightRequestIfProblematic)),this.appendColumnTitle(i,Ve(De.header)),this.appendColumnTitle(i,Ve(De.problem)),this.appendColumnTitle(i,Ve(De.invalidValue));break;case e.CorsIssue.IssueCode.WildcardOriginNotAllowed:this.appendColumnTitle(i,Ve(De.preflightRequestIfProblematic));break;case e.CorsIssue.IssueCode.PreflightResponseInvalid:this.appendColumnTitle(i,Ve(De.preflightRequest)),this.appendColumnTitle(i,Ve(De.problem));break;case e.CorsIssue.IssueCode.OriginMismatch:this.appendColumnTitle(i,Ve(De.preflightRequestIfProblematic)),this.appendColumnTitle(i,Ve(De.initiatorContext)),this.appendColumnTitle(i,Ve(De.allowedOrigin));break;case e.CorsIssue.IssueCode.AllowCredentialsRequired:this.appendColumnTitle(i,Ve(De.preflightRequestIfProblematic)),this.appendColumnTitle(i,Ve(De.allowCredentialsValueFromHeader));break;case e.CorsIssue.IssueCode.InsecurePrivateNetwork:this.appendColumnTitle(i,Ve(De.resourceAddressSpace)),this.appendColumnTitle(i,Ve(De.initiatorAddressSpace)),this.appendColumnTitle(i,Ve(De.initiatorContext));break;case e.CorsIssue.IssueCode.PreflightAllowPrivateNetworkError:this.appendColumnTitle(i,Ve(De.preflightRequest)),this.appendColumnTitle(i,Ve(De.invalidValue)),this.appendColumnTitle(i,Ve(De.initiatorAddressSpace)),this.appendColumnTitle(i,Ve(De.initiatorContext));break;case e.CorsIssue.IssueCode.MethodDisallowedByPreflightResponse:this.appendColumnTitle(i,Ve(De.preflightRequest)),this.appendColumnTitle(i,Ve(De.disallowedRequestMethod));break;case e.CorsIssue.IssueCode.HeaderDisallowedByPreflightResponse:this.appendColumnTitle(i,Ve(De.preflightRequest)),this.appendColumnTitle(i,Ve(De.disallowedRequestHeader));break;case e.CorsIssue.IssueCode.RedirectContainsCredentials:break;case e.CorsIssue.IssueCode.DisallowedByMode:this.appendColumnTitle(i,Ve(De.initiatorContext)),this.appendColumnTitle(i,Ve(De.sourceLocation));break;case e.CorsIssue.IssueCode.CorsDisabledScheme:this.appendColumnTitle(i,Ve(De.initiatorContext)),this.appendColumnTitle(i,Ve(De.sourceLocation)),this.appendColumnTitle(i,Ve(De.unsupportedScheme));break;case e.CorsIssue.IssueCode.NoCorsRedirectModeNotFollow:this.appendColumnTitle(i,Ve(De.sourceLocation));break;default:f.assertUnhandled(t)}this.affectedResources.appendChild(i);let n=0;for(const e of s)n++,this.#ee(t,e);this.updateAffectedResourceCount(n)}#Ie(e,t){void 0!==t?this.appendIssueDetailCell(e,Ve(t?De.secure:De.insecure)):this.appendIssueDetailCell(e,"")}static getHeaderFromError(e){switch(e){case"InvalidAllowHeadersPreflightResponse":return"Access-Control-Allow-Headers";case"InvalidAllowMethodsPreflightResponse":case"MethodDisallowedByPreflightResponse":return"Access-Control-Allow-Methods";case"PreflightMissingAllowOriginHeader":case"PreflightMultipleAllowOriginValues":case"PreflightInvalidAllowOriginValue":case"MissingAllowOriginHeader":case"MultipleAllowOriginValues":case"InvalidAllowOriginValue":case"WildcardOriginNotAllowed":case"PreflightWildcardOriginNotAllowed":case"AllowOriginMismatch":case"PreflightAllowOriginMismatch":return"Access-Control-Allow-Origin";case"InvalidAllowCredentials":case"PreflightInvalidAllowCredentials":return"Access-Control-Allow-Credentials";case"PreflightMissingAllowPrivateNetwork":case"PreflightInvalidAllowPrivateNetwork":return"Access-Control-Allow-Private-Network";case"RedirectContainsCredentials":case"PreflightDisallowedRedirect":return"Location";case"PreflightInvalidStatus":return"Status-Code"}return""}static getProblemFromError(e){switch(e.corsError){case"InvalidAllowHeadersPreflightResponse":case"InvalidAllowMethodsPreflightResponse":case"PreflightInvalidAllowOriginValue":case"InvalidAllowOriginValue":return Ve(De.problemInvalidValue);case"PreflightMultipleAllowOriginValues":case"MultipleAllowOriginValues":return Ve(De.problemMultipleValues);case"MissingAllowOriginHeader":case"PreflightMissingAllowOriginHeader":return Ve(De.problemMissingHeader);case"PreflightInvalidStatus":return Ve(De.preflightInvalidStatus);case"PreflightDisallowedRedirect":return Ve(De.preflightDisallowedRedirect);case"InvalidResponse":return Ve(De.failedRequest)}throw new Error("Invalid Argument")}#ee(t,s){const i=document.createElement("tr");i.classList.add("affected-resource-directive");const n=s.details(),a=n.corsErrorStatus,r=n.corsErrorStatus.corsError,o={section:p.UIRequestLocation.UIHeaderSection.Response,name:Oe.getHeaderFromError(r)},d={additionalOnClickAction(){l.userMetrics.issuesPanelResourceOpened(e.Issue.IssueCategory.Cors,"Request")}};switch(t){case e.CorsIssue.IssueCode.InvalidHeaderValues:i.appendChild(this.createRequestCell(n.request,d)),this.#G(i,n.isWarning),r.includes("Preflight")?i.appendChild(this.createRequestCell(n.request,{...d,linkToPreflight:!0,highlightHeader:o})):this.appendIssueDetailCell(i,""),this.appendIssueDetailCell(i,Oe.getHeaderFromError(r),"code-example"),this.appendIssueDetailCell(i,Oe.getProblemFromError(n.corsErrorStatus)),this.appendIssueDetailCell(i,n.corsErrorStatus.failedParameter,"code-example");break;case e.CorsIssue.IssueCode.WildcardOriginNotAllowed:i.appendChild(this.createRequestCell(n.request,d)),this.#G(i,n.isWarning),r.includes("Preflight")?i.appendChild(this.createRequestCell(n.request,{...d,linkToPreflight:!0,highlightHeader:o})):this.appendIssueDetailCell(i,"");break;case e.CorsIssue.IssueCode.PreflightResponseInvalid:{i.appendChild(this.createRequestCell(n.request,d)),this.#G(i,n.isWarning);const e="PreflightInvalidStatus"===r?{section:p.UIRequestLocation.UIHeaderSection.General,name:"Status-Code"}:o;i.appendChild(this.createRequestCell(n.request,{...d,linkToPreflight:!0,highlightHeader:e})),this.appendIssueDetailCell(i,Oe.getProblemFromError(n.corsErrorStatus));break}case e.CorsIssue.IssueCode.OriginMismatch:i.appendChild(this.createRequestCell(n.request,d)),this.#G(i,n.isWarning),r.includes("Preflight")?i.appendChild(this.createRequestCell(n.request,{...d,linkToPreflight:!0,highlightHeader:o})):this.appendIssueDetailCell(i,""),this.appendIssueDetailCell(i,n.initiatorOrigin??"","code-example"),this.appendIssueDetailCell(i,n.corsErrorStatus.failedParameter,"code-example");break;case e.CorsIssue.IssueCode.AllowCredentialsRequired:i.appendChild(this.createRequestCell(n.request,d)),this.#G(i,n.isWarning),r.includes("Preflight")?i.appendChild(this.createRequestCell(n.request,{...d,linkToPreflight:!0,highlightHeader:o})):this.appendIssueDetailCell(i,""),this.appendIssueDetailCell(i,n.corsErrorStatus.failedParameter,"code-example");break;case e.CorsIssue.IssueCode.InsecurePrivateNetwork:i.appendChild(this.createRequestCell(n.request,d)),this.#G(i,n.isWarning),this.appendIssueDetailCell(i,n.resourceIPAddressSpace??""),this.appendIssueDetailCell(i,n.clientSecurityState?.initiatorIPAddressSpace??""),this.#Ie(i,n.clientSecurityState?.initiatorIsSecureContext);break;case e.CorsIssue.IssueCode.PreflightAllowPrivateNetworkError:i.appendChild(this.createRequestCell(n.request,d)),this.#G(i,n.isWarning),i.appendChild(this.createRequestCell(n.request,{...d,linkToPreflight:!0,highlightHeader:o})),this.appendIssueDetailCell(i,n.corsErrorStatus.failedParameter,"code-example"),this.appendIssueDetailCell(i,n.clientSecurityState?.initiatorIPAddressSpace??""),this.#Ie(i,n.clientSecurityState?.initiatorIsSecureContext);break;case e.CorsIssue.IssueCode.MethodDisallowedByPreflightResponse:i.appendChild(this.createRequestCell(n.request,d)),this.#G(i,n.isWarning),i.appendChild(this.createRequestCell(n.request,{...d,linkToPreflight:!0,highlightHeader:o})),this.appendIssueDetailCell(i,n.corsErrorStatus.failedParameter,"code-example");break;case e.CorsIssue.IssueCode.HeaderDisallowedByPreflightResponse:i.appendChild(this.createRequestCell(n.request,{...d,highlightHeader:{section:p.UIRequestLocation.UIHeaderSection.Request,name:a.failedParameter}})),this.#G(i,n.isWarning),i.appendChild(this.createRequestCell(n.request,{...d,linkToPreflight:!0,highlightHeader:{section:p.UIRequestLocation.UIHeaderSection.Response,name:"Access-Control-Allow-Headers"}})),this.appendIssueDetailCell(i,n.corsErrorStatus.failedParameter,"code-example");break;case e.CorsIssue.IssueCode.RedirectContainsCredentials:i.appendChild(this.createRequestCell(n.request,{...d,highlightHeader:{section:p.UIRequestLocation.UIHeaderSection.Response,name:Oe.getHeaderFromError(r)}})),this.#G(i,n.isWarning);break;case e.CorsIssue.IssueCode.DisallowedByMode:i.appendChild(this.createRequestCell(n.request,d)),this.#G(i,n.isWarning),this.appendIssueDetailCell(i,n.initiatorOrigin??"","code-example"),this.appendSourceLocation(i,n.location,s.model()?.getTargetIfNotDisposed());break;case e.CorsIssue.IssueCode.CorsDisabledScheme:i.appendChild(this.createRequestCell(n.request,{...d,highlightHeader:{section:p.UIRequestLocation.UIHeaderSection.Response,name:Oe.getHeaderFromError(r)}})),this.#G(i,n.isWarning),this.appendIssueDetailCell(i,n.initiatorOrigin??"","code-example"),this.appendSourceLocation(i,n.location,s.model()?.getTargetIfNotDisposed()),this.appendIssueDetailCell(i,n.corsErrorStatus.failedParameter??"","code-example");break;case e.CorsIssue.IssueCode.NoCorsRedirectModeNotFollow:i.appendChild(this.createRequestCell(n.request,d)),this.#G(i,n.isWarning),this.appendSourceLocation(i,n.location,s.model()?.getTargetIfNotDisposed());break;default:i.appendChild(this.createRequestCell(n.request,d)),this.#G(i,n.isWarning),f.assertUnhandled(t)}this.affectedResources.appendChild(i)}update(){this.clear();const e=this.issue.getCorsIssues();e.size>0?this.#Y(e.values().next().value.code(),e):this.updateAffectedResourceCount(0)}}const Ue={nResources:"{n, plural, =1 {# resource} other {# resources}}",frameId:"Frame",violatingNode:"Violating node"},He=t.i18n.registerUIStrings("panels/issues/GenericIssueDetailsView.ts",Ue),Fe=t.i18n.getLocalizedString.bind(void 0,He);class Ne extends _{getResourceNameWithCount(e){return Fe(Ue.nResources,{n:e})}#Y(e){const t=document.createElement("tr");e.values().next().value.details().frameId&&this.appendColumnTitle(t,Fe(Ue.frameId)),this.affectedResources.appendChild(t);let s=0;for(const t of e)s++,this.#ee(t);this.updateAffectedResourceCount(s)}async#ee(e){const t=document.createElement("tr");t.classList.add("affected-resource-directive");const s=e.details();if(s.frameId&&t.appendChild(this.createFrameCell(s.frameId,e.getCategory())),s.violatingNodeId){const i=e.model()?.target()||null;t.appendChild(await this.createElementCell({backendNodeId:s.violatingNodeId,nodeName:this.violatingNodeIdName(s.errorType),target:i},e.getCategory()))}this.affectedResources.appendChild(t)}violatingNodeIdName(e){return"FormLabelForNameError"===e?t.i18n.lockedString("Label"):Fe(Ue.violatingNode)}update(){this.clear();const e=this.issue.getGenericIssues();e.size>0?this.#Y(e):this.updateAffectedResourceCount(0)}}const Be={nViolations:"{n, plural, =1 {# violation} other {# violations}}",element:"Element",invalidHeaderValue:"Invalid Header Value",request:"Request",untrustworthyOrigin:"Untrustworthy origin"},Ke=t.i18n.registerUIStrings("panels/issues/AttributionReportingIssueDetailsView.ts",Be),We=t.i18n.getLocalizedString.bind(void 0,Ke);class ze extends _{getResourceNameWithCount(e){return We(Be.nViolations,{n:e})}update(){this.clear();const e=this.issue.getAttributionReportingIssues();e.size>0?this.#Y(e.values().next().value.code(),e):this.updateAffectedResourceCount(0)}#Y(e,t){const s=document.createElement("tr");switch(e){case"AttributionReportingIssue::InvalidRegisterSourceHeader":case"AttributionReportingIssue::InvalidRegisterTriggerHeader":case"AttributionReportingIssue::InvalidRegisterOsSourceHeader":case"AttributionReportingIssue::InvalidRegisterOsTriggerHeader":case"AttributionReportingIssue::OsSourceIgnored":case"AttributionReportingIssue::OsTriggerIgnored":case"AttributionReportingIssue::SourceIgnored":case"AttributionReportingIssue::TriggerIgnored":this.appendColumnTitle(s,We(Be.request)),this.appendColumnTitle(s,We(Be.invalidHeaderValue));break;case"AttributionReportingIssue::InsecureContext":case"AttributionReportingIssue::UntrustworthyReportingOrigin":this.appendColumnTitle(s,We(Be.element)),this.appendColumnTitle(s,We(Be.request)),this.appendColumnTitle(s,We(Be.untrustworthyOrigin));break;case"AttributionReportingIssue::PermissionPolicyDisabled":this.appendColumnTitle(s,We(Be.element)),this.appendColumnTitle(s,We(Be.request));break;case"AttributionReportingIssue::SourceAndTriggerHeaders":case"AttributionReportingIssue::WebAndOsHeaders":this.appendColumnTitle(s,We(Be.request))}this.affectedResources.appendChild(s);let i=0;for(const s of t)i++,this.#ee(e,s);this.updateAffectedResourceCount(i)}async#ee(e,t){const s=document.createElement("tr");s.classList.add("affected-resource-directive");const i=t.issueDetails;switch(e){case"AttributionReportingIssue::InvalidRegisterSourceHeader":case"AttributionReportingIssue::InvalidRegisterTriggerHeader":case"AttributionReportingIssue::SourceIgnored":case"AttributionReportingIssue::TriggerIgnored":this.#we(s,i.request),this.appendIssueDetailCell(s,i.invalidParameter||"");break;case"AttributionReportingIssue::InsecureContext":case"AttributionReportingIssue::UntrustworthyReportingOrigin":await this.#ye(s,t),this.#we(s,i.request),this.appendIssueDetailCell(s,i.invalidParameter||"");break;case"AttributionReportingIssue::PermissionPolicyDisabled":await this.#ye(s,t),this.#we(s,i.request);break;case"AttributionReportingIssue::SourceAndTriggerHeaders":this.#we(s,i.request)}this.affectedResources.appendChild(s)}async#ye(e,t){const s=t.issueDetails;if(void 0!==s.violatingNodeId){const i=t.model()?.target()||null;e.appendChild(await this.createElementCell({backendNodeId:s.violatingNodeId,target:i,nodeName:"Attribution source element"},t.getCategory()))}else this.appendIssueDetailCell(e,"")}#we(t,s){if(!s)return void this.appendIssueDetailCell(t,"");const i={additionalOnClickAction(){l.userMetrics.issuesPanelResourceOpened(e.Issue.IssueCategory.AttributionReporting,"Request")}};t.appendChild(this.createRequestCell(s,i))}}const _e={name:"Name",blocked:"blocked",nRequests:"{n, plural, =1 {# request} other {# requests}}",nResources:"{n, plural, =1 {# resource} other {# resources}}",restrictionStatus:"Restriction Status",warned:"Warned",affectedResources:"Affected Resources",learnMoreS:"Learn more: {PH1}",automaticallyUpgraded:"automatically upgraded",hideIssuesLikeThis:"Hide issues like this",unhideIssuesLikeThis:"Unhide issues like this"},je=t.i18n.registerUIStrings("panels/issues/IssueView.ts",_e),Ge=t.i18n.getLocalizedString.bind(void 0,je);class $e extends _{#be(e){let t=0;for(const s of e){const e=document.createElement("tr");e.classList.add("affected-resource-request");const i=this.issue.getCategory();let n=Qe.get(i)||p.UIRequestLocation.UIRequestTabs.Headers;n===p.UIRequestLocation.UIRequestTabs.Headers&&g.Runtime.experiments.isEnabled(g.Runtime.ExperimentName.HEADER_OVERRIDES)&&(n=p.UIRequestLocation.UIRequestTabs.HeadersComponent),e.appendChild(this.createRequestCell(s,{networkTab:n,additionalOnClickAction(){l.userMetrics.issuesPanelResourceOpened(i,"Request")}})),this.affectedResources.appendChild(e),t++}this.updateAffectedResourceCount(t)}getResourceNameWithCount(e){return Ge(_e.nRequests,{n:e})}update(){this.clear();for(const e of this.issue.getBlockedByResponseDetails())return void this.updateAffectedResourceCount(0);this.issue.getCategory()!==e.Issue.IssueCategory.MixedContent?this.#be(this.issue.requests()):this.updateAffectedResourceCount(0)}}const Qe=new Map([[e.Issue.IssueCategory.Cookie,p.UIRequestLocation.UIRequestTabs.Cookies],[e.Issue.IssueCategory.CrossOriginEmbedderPolicy,p.UIRequestLocation.UIRequestTabs.Headers],[e.Issue.IssueCategory.MixedContent,p.UIRequestLocation.UIRequestTabs.Headers]]);class Ze extends _{#ve(e){const t=document.createElement("tr");this.appendColumnTitle(t,Ge(_e.name)),this.appendColumnTitle(t,Ge(_e.restrictionStatus)),this.affectedResources.appendChild(t);let s=0;for(const t of e){const e=t.getDetails();this.appendAffectedMixedContent(e),s++}this.updateAffectedResourceCount(s)}getResourceNameWithCount(e){return Ge(_e.nResources,{n:e})}appendAffectedMixedContent(t){const s=document.createElement("tr");if(s.classList.add("affected-resource-mixed-content"),t.request){let i=Qe.get(this.issue.getCategory())||p.UIRequestLocation.UIRequestTabs.Headers;i===p.UIRequestLocation.UIRequestTabs.Headers&&g.Runtime.experiments.isEnabled(g.Runtime.ExperimentName.HEADER_OVERRIDES)&&(i=p.UIRequestLocation.UIRequestTabs.HeadersComponent),s.appendChild(this.createRequestCell(t.request,{networkTab:i,additionalOnClickAction(){l.userMetrics.issuesPanelResourceOpened(e.Issue.IssueCategory.MixedContent,"Request")}}))}else{const e=(i=t.insecureURL,(/[^/]+$/.exec(i)||/[^/]+\/$/.exec(i)||[""])[0]);this.appendIssueDetailCell(s,e,"affected-resource-mixed-content-info").title=t.insecureURL}var i;this.appendIssueDetailCell(s,Ze.translateStatus(t.resolutionStatus),"affected-resource-mixed-content-info"),this.affectedResources.appendChild(s)}static translateStatus(e){switch(e){case"MixedContentBlocked":return Ge(_e.blocked);case"MixedContentAutomaticallyUpgraded":return Ge(_e.automaticallyUpgraded);case"MixedContentWarning":return Ge(_e.warned)}}update(){this.clear(),this.#ve(this.issue.getMixedContentIssues())}}class Je extends s.TreeOutline.TreeElement{#Re;#ke;toggleOnClick;affectedResources;#xe;#P;#Se=null;#Te;#Ae;#Ee=!0;#Le;#Me=!1;constructor(e,t){super(),this.#Re=e,this.#ke=t,this.#Ae=new r.Throttler.Throttler(250),this.toggleOnClick=!0,this.listItemElement.classList.add("issue"),this.childrenListElement.classList.add("body"),this.childrenListElement.classList.add(Je.getBodyCSSClass(this.#Re.getKind())),this.affectedResources=this.#Pe(),this.#xe=[new ie(this,this.#Re),new de(this,this.#Re),new $e(this,this.#Re),new Ze(this,this.#Re),new Ae(this,this.#Re),new ye(this,this.#Re),new Q(this,this.#Re),new Y(this,this.#Re),new ke(this,this.#Re),new he(this,this.#Re),new Oe(this,this.#Re),new Ne(this,this.#Re),new pe(this,this.#Re),new ze(this,this.#Re),new ne(this,this.#Re),new Pe(this,this.#Re)],this.#Le=new h.HideIssuesMenu.HideIssuesMenu,this.#P=null,this.#Te=!1}setIssue(e){this.#Re!==e&&(this.#Ee=!0),this.#Re=e,this.#xe.forEach((t=>t.setIssue(e)))}static getBodyCSSClass(t){switch(t){case e.Issue.IssueKind.BreakingChange:return"issue-kind-breaking-change";case e.Issue.IssueKind.PageError:return"issue-kind-page-error";case e.Issue.IssueKind.Improvement:return"issue-kind-improvement"}}getIssueTitle(){return this.#ke.title}onattach(){this.#Me?this.update():this.createContent()}createContent(){this.#N(),this.#De(),this.appendChild(this.affectedResources);for(const e of this.#xe)this.appendAffectedResource(e),e.update();this.#qe(),this.updateAffectedResourceVisibility(),this.#Me=!0}appendAffectedResource(e){this.affectedResources.appendChild(e)}#N(){const e=document.createElement("div");e.classList.add("header"),this.#Se=new u.Icon.Icon,this.#Se.classList.add("leading-issue-icon"),this.#P=document.createElement("span");const t=new d.Adorner.Adorner;t.data={name:"countWrapper",content:this.#P},t.classList.add("aggregated-issues-count"),e.appendChild(this.#Se),e.appendChild(t);const s=document.createElement("div");s.classList.add("title"),s.textContent=this.#ke.title,e.appendChild(s),this.#Le&&e.appendChild(this.#Le),this.#Ve(),this.listItemElement.appendChild(e)}onexpand(){if(l.userMetrics.issuesPanelIssueExpanded(this.#Re.getCategory()),this.#Ee&&this.#re(),!this.#Te){this.#Te=!0;for(const e of this.#xe)e.expandIfOneResource()}}#Ve(){if(this.#Se){const t=this.#Re.getKind();this.#Se.data=o.IssueCounter.getIssueKindIconData(t),this.#Se.title=e.Issue.getIssueKindDescription(t)}if(this.#P&&(this.#P.textContent=`${this.#Re.getAggregatedIssuesCount()}`),this.listItemElement.classList.toggle("hidden-issue",this.#Re.isHidden()),this.#Le){const t={menuItemLabel:this.#Re.isHidden()?Ge(_e.unhideIssuesLikeThis):Ge(_e.hideIssuesLikeThis),menuItemAction:()=>{const t=e.IssuesManager.getHideIssueByCodeSetting(),s=t.get();s[this.#Re.code()]=this.#Re.isHidden()?"Unhidden":"Hidden",t.set(s)}};this.#Le.data=t}}updateAffectedResourceVisibility(){const e=this.#xe.every((e=>e.isEmpty()));this.affectedResources.hidden=e}#Pe(){const e=new s.TreeOutline.TreeElement;return e.setCollapsible(!1),e.setExpandable(!0),e.expand(),e.selectable=!1,e.listItemElement.classList.add("affected-resources-label"),e.listItemElement.textContent=Ge(_e.affectedResources),e.childrenListElement.classList.add("affected-resources"),e}#De(){const e=new s.TreeOutline.TreeElement;e.setCollapsible(!1),e.selectable=!1;const t=new c.MarkdownView.MarkdownView;t.data={tokens:this.#ke.markdown},e.listItemElement.appendChild(t),this.appendChild(e)}#qe(){if(0===this.#ke.links.length)return;const e=new s.TreeOutline.TreeElement;e.setCollapsible(!1),e.listItemElement.classList.add("link-wrapper");const t=e.listItemElement.createChild("ul","link-list");for(const e of this.#ke.links){const i=s.Fragment.html`<x-link class="link devtools-link" tabindex="0" href="${e.link}">${Ge(_e.learnMoreS,{PH1:e.linkTitle})}</x-link>`,n=new u.Icon.Icon;n.data={iconName:"open-externally",color:"var(--icon-link)",width:"16px",height:"16px"},n.classList.add("link-icon"),i.prepend(n),i.addEventListener("x-link-invoke",(()=>{l.userMetrics.issuesPanelResourceOpened(this.#Re.getCategory(),"LearnMore")}));t.createChild("li").appendChild(i)}this.appendChild(e)}#re(){this.expanded&&(this.#xe.forEach((e=>e.update())),this.updateAffectedResourceVisibility()),this.#Ee=!this.expanded,this.#Ve()}update(){this.#Ae.schedule((async()=>this.#re()))}clear(){this.#xe.forEach((e=>e.clear()))}getIssueKind(){return this.#Re.getKind()}isForHiddenIssue(){return this.#Re.isHidden()}toggle(e){e||void 0===e&&!this.expanded?this.expand():this.collapse()}}var Xe=Object.freeze({__proto__:null,IssueView:Je});const Ye={hideAllCurrentPageErrors:"Hide all current Page Errors",hideAllCurrentBreakingChanges:"Hide all current Breaking Changes",hideAllCurrentImprovements:"Hide all current Improvements"},et=t.i18n.registerUIStrings("panels/issues/IssueKindView.ts",Ye),tt=t.i18n.getLocalizedString.bind(void 0,et);function st(){return r.Settings.Settings.instance().createSetting("groupIssuesByKind",!1)}class it extends s.TreeOutline.TreeElement{#Oe;#Ue;constructor(t){super(void 0,!0),this.#Oe=t,this.#Ue=document.createElement("span"),this.toggleOnClick=!0,this.listItemElement.classList.add("issue-kind"),this.listItemElement.classList.add(function(t){switch(t){case e.Issue.IssueKind.BreakingChange:return"breaking-changes";case e.Issue.IssueKind.Improvement:return"improvements";case e.Issue.IssueKind.PageError:return"page-errors"}}(t)),this.childrenListElement.classList.add("issue-kind-body")}getKind(){return this.#Oe}getHideAllCurrentKindString(){switch(this.#Oe){case e.Issue.IssueKind.PageError:return tt(Ye.hideAllCurrentPageErrors);case e.Issue.IssueKind.Improvement:return tt(Ye.hideAllCurrentImprovements);case e.Issue.IssueKind.BreakingChange:return tt(Ye.hideAllCurrentBreakingChanges)}}#N(){const t=document.createElement("div");t.classList.add("header");const s=new u.Icon.Icon;s.data=o.IssueCounter.getIssueKindIconData(this.#Oe),s.classList.add("leading-issue-icon");const i=new d.Adorner.Adorner;i.data={name:"countWrapper",content:this.#Ue},i.classList.add("aggregated-issues-count"),this.#Ue.textContent="0";const n=document.createElement("div");n.classList.add("title"),n.textContent=e.Issue.getIssueKindName(this.#Oe);const a=new h.HideIssuesMenu.HideIssuesMenu;a.classList.add("hide-available-issues"),a.data={menuItemLabel:this.getHideAllCurrentKindString(),menuItemAction:()=>{const t=e.IssuesManager.getHideIssueByCodeSetting(),s=t.get();for(const t of e.IssuesManager.IssuesManager.instance().issues())t.getKind()===this.#Oe&&(s[t.code()]="Hidden");t.set(s)}},t.appendChild(s),t.appendChild(i),t.appendChild(n),t.appendChild(a),this.listItemElement.appendChild(t)}onattach(){this.#N(),this.expand()}update(e){this.#Ue.textContent=`${e}`}}const nt={crossOriginEmbedderPolicy:"Cross Origin Embedder Policy",mixedContent:"Mixed Content",samesiteCookie:"SameSite Cookie",heavyAds:"Heavy Ads",contentSecurityPolicy:"Content Security Policy",other:"Other",lowTextContrast:"Low Text Contrast",cors:"Cross Origin Resource Sharing",groupDisplayedIssuesUnder:"Group displayed issues under associated categories",groupByCategory:"Group by category",groupDisplayedIssuesUnderKind:"Group displayed issues as Page errors, Breaking changes and Improvements",groupByKind:"Group by kind",includeCookieIssuesCausedBy:"Include cookie Issues caused by third-party sites",includeThirdpartyCookieIssues:"Include third-party cookie issues",onlyThirdpartyCookieIssues:"Only third-party cookie issues detected so far",noIssuesDetectedSoFar:"No issues detected so far",attributionReporting:"Attribution Reporting `API`",quirksMode:"Quirks Mode",generic:"Generic"},at=t.i18n.registerUIStrings("panels/issues/IssuesPane.ts",nt),rt=t.i18n.getLocalizedString.bind(void 0,at);class ot extends s.TreeOutline.TreeElement{#He;constructor(e){super(),this.#He=e,this.toggleOnClick=!0,this.listItemElement.classList.add("issue-category"),this.childrenListElement.classList.add("issue-category-body")}getCategoryName(){switch(this.#He){case e.Issue.IssueCategory.CrossOriginEmbedderPolicy:return rt(nt.crossOriginEmbedderPolicy);case e.Issue.IssueCategory.MixedContent:return rt(nt.mixedContent);case e.Issue.IssueCategory.Cookie:return rt(nt.samesiteCookie);case e.Issue.IssueCategory.HeavyAd:return rt(nt.heavyAds);case e.Issue.IssueCategory.ContentSecurityPolicy:return rt(nt.contentSecurityPolicy);case e.Issue.IssueCategory.LowTextContrast:return rt(nt.lowTextContrast);case e.Issue.IssueCategory.Cors:return rt(nt.cors);case e.Issue.IssueCategory.AttributionReporting:return rt(nt.attributionReporting);case e.Issue.IssueCategory.QuirksMode:return rt(nt.quirksMode);case e.Issue.IssueCategory.Generic:return rt(nt.generic);case e.Issue.IssueCategory.Other:return rt(nt.other)}}onattach(){this.#N()}#N(){const e=document.createElement("div");e.classList.add("header");const t=document.createElement("div");t.classList.add("title"),t.textContent=this.getCategoryName(),e.appendChild(t),this.listItemElement.appendChild(e)}}function dt(){return r.Settings.Settings.instance().createSetting("groupIssuesByCategory",!1)}let lt;class ut extends s.Widget.VBox{#Fe;#Ne;#Be;#Ke;#We;#ze;#_e;#u;#je;#Ge=Promise.resolve();constructor(){super(!0),this.contentElement.classList.add("issues-pane"),this.#Fe=new Map,this.#Be=new Map,this.#Ne=new Map,this.#Ke=null,this.#$e(),this.#We=new s.TreeOutline.TreeOutlineInShadow,this.#We.setShowSelectionOnKeyboardFocus(!0),this.#We.contentElement.classList.add("issues"),this.contentElement.appendChild(this.#We.element),this.#ze=new F,this.#We.appendChild(this.#ze),this.#_e=document.createElement("div"),this.#_e.classList.add("issues-pane-no-issues"),this.contentElement.appendChild(this.#_e),this.#u=e.IssuesManager.IssuesManager.instance(),this.#je=new q(this.#u),this.#je.addEventListener("AggregatedIssueUpdated",this.#Qe,this),this.#je.addEventListener("FullUpdateRequired",this.#Ze,this),this.#ze.hidden=0===this.#u.numberOfHiddenIssues(),this.#Ze(),this.#u.addEventListener("IssuesCountUpdated",this.#Je,this)}static instance(e={forceNew:null}){const{forceNew:t}=e;return lt&&!t||(lt=new ut),lt}elementsToRestoreScrollPositionsFor(){return[this.#We.element]}#$e(){const t=this.contentElement.createChild("div","issues-toolbar-container");new s.Toolbar.Toolbar("issues-toolbar-left",t);const i=new s.Toolbar.Toolbar("issues-toolbar-right",t),n=dt(),a=new s.Toolbar.ToolbarSettingCheckbox(n,rt(nt.groupDisplayedIssuesUnder),rt(nt.groupByCategory));a.setVisible(!1),i.appendToolbarItem(a),n.addChangeListener((()=>{this.#Xe(!0)}));const r=st(),d=new s.Toolbar.ToolbarSettingCheckbox(r,rt(nt.groupDisplayedIssuesUnderKind),rt(nt.groupByKind));i.appendToolbarItem(d),r.addChangeListener((()=>{this.#Xe(!0)})),d.setVisible(!0);const l=e.Issue.getShowThirdPartyIssuesSetting();this.#Ke=new s.Toolbar.ToolbarSettingCheckbox(l,rt(nt.includeCookieIssuesCausedBy),rt(nt.includeThirdpartyCookieIssues)),i.appendToolbarItem(this.#Ke),this.setDefaultFocusedElement(this.#Ke.inputElement),i.appendSeparator();const u=new o.IssueCounter.IssueCounter;u.data={tooltipCallback:()=>{const t=o.IssueCounter.getIssueCountsEnumeration(e.IssuesManager.IssuesManager.instance(),!1);u.title=t},displayMode:"ShowAlways",issuesManager:e.IssuesManager.IssuesManager.instance()},u.id="console-issues-counter";const c=new s.Toolbar.ToolbarItem(u);return i.appendToolbarItem(c),{toolbarContainer:t}}#Qe(e){this.#Ye(e.data)}#Ye(e){this.#Ge=this.#Ge.then((()=>this.#et(e)))}async#et(t){let i=this.#Ne.get(t.aggregationKey());if(i){i.setIssue(t);const e=this.#tt(t);i.parent===e||e instanceof s.TreeOutline.TreeOutline&&i.parent===e.rootElement()||(i.parent?.removeChild(i),this.appendIssueViewToParent(i,e))}else{const s=t.getDescription();if(!s)return void console.warn("Could not find description for issue code:",t.code());const n=await e.MarkdownIssueDescription.createIssueDescriptionFromMarkdown(s);i=new Je(t,n),this.#Ne.set(t.aggregationKey(),i);const a=this.#tt(t);this.appendIssueViewToParent(i,a)}i.update(),this.#Je()}appendIssueViewToParent(e,t){t.appendChild(e,((e,t)=>e instanceof F?1:t instanceof F?-1:e instanceof Je&&t instanceof Je?e.getIssueTitle().localeCompare(t.getIssueTitle()):(console.error("The issues tree should only contain IssueView objects as direct children"),0)))}#tt(t){if(t.isHidden())return this.#ze;if(st().get()){const s=t.getKind(),i=this.#Be.get(s);if(i)return i;const n=new it(s);return this.#We.appendChild(n,((t,s)=>t instanceof it&&s instanceof it?function(t,s){return t.getKind()===s.getKind()?0:t.getKind()===e.Issue.IssueKind.PageError||t.getKind()===e.Issue.IssueKind.BreakingChange&&s.getKind()===e.Issue.IssueKind.Improvement?-1:1}(t,s):0)),this.#Be.set(s,n),n}if(dt().get()){const e=t.getCategory(),s=this.#Fe.get(e);if(s)return s;const i=new ot(e);return this.#We.appendChild(i,((e,t)=>e instanceof ot&&t instanceof ot?e.getCategoryName().localeCompare(t.getCategoryName()):0)),this.#Fe.set(e,i),i}return this.#We}#st(e,t){for(const[s,i]of Array.from(e.entries()))t?.has(s)||(i.parent&&i.parent.removeChild(i),e.delete(s))}#Ze(){this.#Xe(!1)}#Xe(e){if(this.#st(this.#Fe,e?void 0:this.#je.aggregatedIssueCategories()),this.#st(this.#Be,e?void 0:this.#je.aggregatedIssueKinds()),this.#st(this.#Ne,e?void 0:this.#je.aggregatedIssueCodes()),this.#je)for(const e of this.#je.aggregatedIssues())this.#Ye(e);this.#Je()}#it(){for(const e of this.#Be.values()){const t=this.#u.numberOfIssues(e.getKind());e.update(t)}}#Je(){this.#nt(this.#u.numberOfIssues(),this.#u.numberOfHiddenIssues()),st().get()&&this.#it()}#nt(e,t){if(e>0||t>0){this.#ze.hidden=0===t,this.#ze.update(t),this.#We.element.hidden=!1,this.#_e.style.display="none";const e=this.#We.firstChild();e&&(e.select(!0),this.setDefaultFocusedElement(e.listItemElement))}else{this.#We.element.hidden=!0,this.#Ke&&this.setDefaultFocusedElement(this.#Ke.inputElement);const e=this.#u.numberOfAllStoredIssues()>0;this.#_e.textContent=rt(e?nt.onlyThirdpartyCookieIssues:nt.noIssuesDetectedSoFar),this.#_e.style.display="flex"}}async reveal(e){await this.#Ge;const t=this.#je.keyForIssue(e),s=this.#Ne.get(t);if(s){if(s.isForHiddenIssue()&&(this.#ze.expand(),this.#ze.reveal()),st().get()&&!s.isForHiddenIssue()){const e=this.#Be.get(s.getIssueKind());e?.expand(),e?.reveal()}s.expand(),s.reveal(),s.select(!1,!0)}}wasShown(){super.wasShown(),this.#We.registerCSSFiles([B]),this.registerCSSFiles([N])}}var ct=Object.freeze({__proto__:null,getGroupIssuesByCategorySetting:dt,IssuesPane:ut});let pt;class ht{static instance(e={forceNew:null}){const{forceNew:t}=e;return pt&&!t||(pt=new ht),pt}async reveal(t){if(!(t instanceof e.Issue.Issue))throw new Error("Internal error: not a issue");await s.ViewManager.ViewManager.instance().showView("issues-pane");const i=s.ViewManager.ViewManager.instance().view("issues-pane");if(i){const e=await i.widget();if(!(e instanceof ut))throw new Error("Expected issues pane to be an instance of IssuesPane");await e.reveal(t)}}}var gt=Object.freeze({__proto__:null,IssueRevealer:ht});export{P as CSPViolationsView,V as IssueAggregator,gt as IssueRevealer,Xe as IssueView,ct as IssuesPane};
